<template>
  <div class="layout-col plr15 pb15">
    <!-- leftNav -->
    <div class="ww100">
      <leftNav :msg="msg" @fn="changeHome" v-model:numSun="numSun" />
      <testB></testB>
    </div>
   <HelloWorld />
  </div>
</template>

<script lang="ts" setup>
import leftTop1 from "@/components/HelloWorld";
import leftNav from "@/components/LeftNav";
import testB from "./testB";
import scheduled from "@/utils/scheduled"
const { createScheduled } = scheduled()
const { proxy }:any = getCurrentInstance()
const configStore = proxy.configStore()
const publicStore = proxy.publicStore()
const state = reactive({
	...configStore.$state,
	...publicStore.$state,
})
let msg = $ref('这是父传过去的数据')
let numSun = $ref(150)
const changeHome = (n) =>{
  console.log(n)
}
onMounted(async() => {
	await init()
  await typeScriptDemo()
	createScheduled('home', 10*60*1000, () => { init() })
})
const typeScriptDemo = async() =>{
  // 基础类型
  const a: string = 'foo'
  const b: number = 123
  const c: boolean = true
  // Symbol 类型
  const h: symbol = Symbol()
  // Object 类型
  const fn: object = function (){}
  const obj: object = {}
  const arr: object = []
  // 数组类型
  const arr1: Array<number> = [1,2,3]
  const arr2: number[] = [2,3,4]
  // 元组类型
  const entries:[string, number][] = Object.entries({ foo: 123, bar: 456});
  const [key, value] = entries[0];
  console.log(key + ' ' + value)
  // 枚举类型
  enum PostStatus1 {
    Draft, // 0
    Unpublished, // 1
    Published // 2
  }

  enum PostStatus2 {
    Draft = 6, // 6
    Unpublished, // 7
    Published2 // 8
  }

  const post = {
    title: 'Hello TypeScript',
    content: 'TypeScript is a typed superset of JavaScript.',
    status: PostStatus2.Draft //
  }
  console.log(post.status)


}
const init = async() => {
	console.log('init...', state)
	let query = {"o": "o_wf_voltage"}
	let params = {queryApi: query}
	let res = await publicStore.post(params, {ip: '10.8.3.28:8808'})
  state._public.obj = 2
  console.log('init...', state)
}

</script>

<style scoped lang="scss">

</style>
